#include <iostream>
using namespace std;

#include "Observer.h"
#include "Observerable.h"

class News : public Observerable {
public:
    virtual void GetSomeNews(string str) {
        SetChange("News: " + str);
    }
};

class User1 : public Observer {
    virtual void Update(void * pArg) {
        cout << "User 1 Got News;" << endl;
    }
};

class User2 : public Observer {
    virtual void Update(void * pArg) {
        cout << "User 2 Got News;" << endl;
    }
};

int main() {
    std::cout << "Hello, World!" << std::endl;

    User1 u1;
    User2 u2;

    News n1;
    n1.GetSomeNews("T0");

    cout << n1.GetObserverCount() << endl;

    n1.Attach(&u1);
    n1.Attach(&u2);
    n1.GetSomeNews("T1");
    cout << n1.GetObserverCount() << endl;

    n1.Detach(&u2);
    n1.GetSomeNews("T2");
    cout << n1.GetObserverCount() << endl;

    n1.DetachAll();
    n1.GetSomeNews("T3");
    cout << n1.GetObserverCount() << endl;

    return 0;
}
